//
// Created by 罗俊华 on 2022/2/9.
//

#ifndef CPP_LEARNING_CAMERA_H
#define CPP_LEARNING_CAMERA_H

#include <string>
#include <iostream>

using std::string;

using std::cout;
using std::endl;

class Camera {
private:
    string name;
public:
    Camera(string name_) : name(name_) {}


    /**
     * 拷贝构造函数一定要是 const &
     * */
    Camera(const Camera &c) {
        this->name = c.name;
        cout << this->name << "，引用被拷贝了" << endl;
    }


    Camera &operator=(Camera &c) {
        this->name = c.name;
        cout << this->name << "，引用赋值" << endl;

        return *this;
    }

    Camera &operator=(Camera *c) {
        this->name = c->name;
        cout << this->name << "，指针赋值" << endl;

        return *this;
    }


    virtual ~Camera() {}

    friend void output(Camera *camera);
};

void output(Camera *camera) {
    cout << camera->name << "\n";
}

#endif //CPP_LEARNING_CAMERA_H
